Python 組み込み関数 isinstance
isinstance(object, classinfo)
サブクラスを考慮する
object 引数が classinfo 引数に指定した型、またはその (直接、間接、または 仮想 の) サブクラスのインスタンスである場合に True を返します。
第2引数はタプルで渡せる
If classinfo is a tuple of type objects (or recursively, other such tuples) or a Union Type of multiple types, return True if object is an instance of any of the types.
「typeオブジェクトのタプルまたはUnion型のとき、objectがいずれかの型のインスタンスならTrueを返す」